package main.KBProcess;

import java.io.Serializable;
import main.Ontology.ElementOntologyFactory;
import main.Ontology.ElementOntologySet;

/*
 Unstructured Text Entity Extraction System (UTEES)
 Programmer:	John Talburt
 *              Isaac Osesina
 Date:		September 13, 2008
 Filename:	DefaultElement
 Purpose:	Data Structure to hold XML Element parse from UTEES_Index
 Element Type = Entity(e) or Context(c)
 Eelement Tag and Element Value
 */

public class DefaultElement implements Element, Serializable, Cloneable  {
	private ElementType type;
	private String label;
	private String docLanguage;
	private String docType;
	private String value;
	private int indexOf;
	private int labelIndex;
	private int docID;
	private int sequenceInDoc;
    private Element preElement;
    private Element postElement;
	
	private ElementOntologyFactory elementOntologyFactory;
    private KnowledgeBaseDocument knowledgeBaseDocument;

	public DefaultElement(ElementType type, String tag, String value, int pos,
			int tagIdx, int docID, ElementOntologyFactory elementOntologyFactory) {
		this.elementOntologyFactory = elementOntologyFactory;
		this.type = type;
		label = tag;
		this.value = value;
		indexOf = pos;
		labelIndex = tagIdx;
		this.docID = docID;
	}

	public DefaultElement(ElementOntologyFactory elementOntologyFactory) {
                this.elementOntologyFactory = elementOntologyFactory;
	}

	@Override
	public void setLabel(String label) {
		this.label = label!=null ? label.toLowerCase():label;
	}

	@Override
	public void setType(ElementType type) {
		this.type = type;
	}

	@Override
	public void setValue(String value) {
		this.value = value;
	}

	@Override
	public void setIndexOf(int indexOf) {
		this.indexOf = indexOf;
	}

	@Override
	public void setLabelIndex(int labelIndex) {
		this.labelIndex = labelIndex;
	}

	@Override
	public ElementType getType() {
		return type;
	}

	@Override
	public String getLabel() {
		return label;
	}

	@Override
	public String getValue() {
		return value;
	}

	@Override
	public int getIndexOf() {
		return indexOf;
	}

	@Override
	public int getLabelIndex() {
		return labelIndex;
	}

	@Override
	public int getDocID() {
		return docID;
	}

	@Override
	public void setDocID(int docID) {
		this.docID = docID;
	}

	@Override
	public void setDocumentLanguage(String language) {
		this.docLanguage = language!=null ? language.toLowerCase():language;
	}

	@Override
	public String getDocumentLanguage() {
		return docLanguage;
	}

	@Override
	public void setDocumentCategory(String docType) {
		this.docType = docType!=null ? docType.toLowerCase():docType;
	}

	@Override
	public String getDocumentCategory() {
		return docType;
	}

	@Override
	public int getSequenceInDoc() {
		return sequenceInDoc;
	}

	@Override
	public void setSequenceInDoc(int sequenceInDoc) {
		this.sequenceInDoc = sequenceInDoc;
	}

	@Override
	public ElementOntologySet getOntologies() {
		return elementOntologyFactory.createElementOntologies(this);
	}
        
        @Override
        public String toString() {
            String s = docID + ", " + docLanguage + ", " + label + ", " + docType + ", " + value;
            return s;
        }

    @Override
    public Element getPostElement() {
        return postElement;
    }

    @Override
    public void setPostElement(Element postElement) {
        this.postElement = postElement;
    }

    @Override
    public Element getPreElement() {
        return preElement;
    }

    @Override
    public void setPreElement(Element preElement) {
        this.preElement = preElement;
    }

    @Override
    public KnowledgeBaseDocument getKnowledgeBaseDocument() {
        return knowledgeBaseDocument;
    }

    @Override
    public void setKnowledgeBaseDocument(KnowledgeBaseDocument kbDocument) {
        knowledgeBaseDocument = kbDocument;
    }

  
}
